﻿package gui;
import java.io.*;


//класс - список отображаемых запущенных процессов - дописать еще
public class ProcessTaskList extends javax.swing.JFrame {

    public ProcessTaskList(String action) {
        initComponents();
        this.setVisible(true);
        this.listofProcess.setVisible(true);
        String line;
        try
        {//код стайл
            Process p = Runtime.getRuntime().exec(System.getenv("windir") +"\\system32\\"+"tasklist.exe");
            BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
	while ((line = input.readLine()) != null) {
            this.listofProcess.add(line);
	}
	input.close();
	} catch (Exception err) {
	}
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        listofProcess = new java.awt.List();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Запущенные процессы");

        listofProcess.setPreferredSize(new java.awt.Dimension(400, 300));
        listofProcess.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                listofProcessItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(listofProcess, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(listofProcess, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>                        

    //выбрали процесс
    private void listofProcessItemStateChanged(java.awt.event.ItemEvent evt) {                                               
        //action=this.listofProcess.getSelectedItem().toString();
    }                                              

    // Variables declaration - do not modify                     
    private java.awt.List listofProcess;
    // End of variables declaration                   
}
